
// Compiler implementation of the D programming language
// Copyright (c) 1999-2008 by Digital Mars
// All Rights Reserved
// written by Walter Bright
// http://www.digitalmars.com
// License for redistribution is by either the Artistic License
// in artistic.txt, or the GNU General Public License in gnu.txt.
// See the included readme.txt for details.

#ifndef DMD_ENUM_H
#define DMD_ENUM_H

#ifdef __DMC__
#pragma once
#endif /* __DMC__ */

#include "../l_service/c_ds/root.h"
#include "dsymbol.h"

struct Identifier;
struct Type;
struct E_Expression;
#ifdef _DH
struct HdrGenState;
#endif


struct P_EnumDeclaration : P_ScopeDsymbol
{   /* enum ident : memtype { ... }
     */
    Type *type;			// the TypeEnum
    Type *memtype;		// type of the members

#if V1
    integer_t maxval;
    integer_t minval;
    integer_t defaultval;	// default initializer
#else
    E_Expression *maxval;
    E_Expression *minval;
    E_Expression *defaultval;	// default initializer

    Scope *scope;		// !=NULL means context to use
#endif
    int isdeprecated;

    P_EnumDeclaration(Loc loc, Identifier *id, Type *memtype);
    P_Dsymbol *syntaxCopy(P_Dsymbol *s);
    void semantic(Scope *sc);
    int oneMember(P_Dsymbol **ps);
    void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
    Type *getType();
    const char *kind();
#if V2
    P_Dsymbol *search(Loc, Identifier *ident, int flags);
#endif
    int isDeprecated();			// is P_Dsymbol deprecated?

    void emitComment(Scope *sc);
    void toDocBuffer(OutBuffer *buf);

    P_EnumDeclaration *isEnumDeclaration() { return this; }

    void toObjFile(int multiobj);			// compile to .obj file
    void toDebug();
    int cvMember(unsigned char *p);

    Symbol *sinit;
    Symbol *toInitializer();
};


struct P_EnumMember : P_Dsymbol
{
    E_Expression *value;
    Type *type;

    P_EnumMember(Loc loc, Identifier *id, E_Expression *value, Type *type);
    P_Dsymbol *syntaxCopy(P_Dsymbol *s);
    void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
    const char *kind();

    void emitComment(Scope *sc);
    void toDocBuffer(OutBuffer *buf);

    P_EnumMember *isEnumMember() { return this; }
};

#endif /* DMD_ENUM_H */
